/**
*
*
*/

function Slideshow(parent) {
    this.slides = $(parent).children();
    this.slidesCount = this.slides.size();
    this.currentElemIdx = 0;
    this.delay = 5000;
    
    startSlideshow(this);
}    
var startSlideshow = function(slideshow) {
	$(slideshow.slides[slideshow.currentElemIdx]).show();
	setInterval( function() {nextSlide(slideshow); }, slideshow.delay);
}
var nextSlide = function(slideshow) {
	updateSlide(slideshow);
}
var updateSlide = function(slideshow) {
	$(slideshow.slides[slideshow.currentElemIdx]).hide();
	checkSlide(slideshow);
	$(slideshow.slides[slideshow.currentElemIdx]).show();
}
var checkSlide = function(slideshow) {
	if (slideshow.currentElemIdx == slideshow.slidesCount - 1) { slideshow.currentElemIdx = 0; }
	else { slideshow.currentElemIdx++; } 
}
